package com.magenta.maxoptra.gis;

import java.util.ArrayList;
import java.util.List;

/**
 * User: KuznetsovD
 * Date: 26.10.11
 * Time: 18:04
 */
public enum MapProviderType {
    yahoo("Yahoo", "<yahoo-label>"),
    google("Google Maps", "<google-label>"),
    map24("Navteq Map24", "<map24-label>"),
    decarta("Decarta", "<decarta-label>"),
    ingit("Ingit", "<ingit-label>"),
    openstreetmap("Open Street Map", "<openstreetmap-label>"),
    geoserver("Geo Server", "<geoserver-label>"),
    geobase("Telogis Geobase", "<geobase-label>"),
    yournavigation("YourNavigation.Org", "<yournavigation-label>"),
    yandex("Yandex", "<yandex-label>"),
    nominatim("Nominatim", "<nominatim-label>"),
    progorod("Progorod", "<progorod-label>"),
    cloudmade("Cloudmade", "<cloudmade-label>"),
    osrm("OSRM", "<osrm-label>"),
    mapquest("MapQuest Maps","<mapquest-label>"),
    nokiahere("NokiaHere Maps","<nokiahere-label>"),
    ptv("Ptv xServer","<ptv-label>"),
    geoinformsputnik("Geo Inform Sputnik","<geoinformsputnik-label>");

    String description;

    String label;

    public GISAccountProperty[] getGisProperties() {
        switch (this) {
            case yahoo:
                return YahooAttribute.values();
            case google:
                return GoogleMapAttribute.values();
            case map24:
                return Map24Attribute.values();
            case decarta:
                return DecartaAttribute.values();
            case ingit:
                return IngitAttribute.values();
            case geobase:
                return GeobaseAttribute.values();
            case geoserver:
                return GeoserverAttribute.values();
            case openstreetmap:
                return OpenstreetMapAttribute.values();
            case yournavigation:
                return YournavigationAttribute.values();
            case yandex:
                return YandexAttribute.values();
            case nominatim:
                return NominatimMapAttribute.values();
            case geoinformsputnik:
                return GeoInformSputnikMapAttribute.values();
            case progorod:
                return ProgorodMapAttribute.values();
            case cloudmade:
                return CloudmadeMapAttribute.values();
            case osrm:
                return OsrmMapAttribute.values();
            case mapquest:
                return MapQuestAttribute.values();
            case nokiahere:
                return NokiaHereAttribute.values();
            case  ptv:
                return PtvMapAttribute.values();
            default:
                return null;
        }
    }

    public String getDescription() {
        return description;
    }

    public String getLabel() {
        return label;
    }

    MapProviderType(String description, String label) {
        this.description = description;
        this.label = label;
    }

    /**
     * РЎРїРёСЃРѕРє РїСЂРѕРІР°Р№РґРµСЂРѕРІ, РґР» РєРѕС‚РѕСЂС‹С… MapKey РЅРµ РЅСѓР¶РЅС‹.
     */
    final static List<MapProviderType> providersWithoutMapKeys = new ArrayList<MapProviderType>();

    static {
        providersWithoutMapKeys.add(ingit);
        providersWithoutMapKeys.add(geoserver);
        providersWithoutMapKeys.add(openstreetmap);
        providersWithoutMapKeys.add(geobase);
        providersWithoutMapKeys.add(nominatim);
    }

    /**
     * @param providerType С‚РёРї РїСЂРѕРІР°Р№РґРµСЂ РєР°СЂС‚
     * @return <b>true</b> РµСЃР»Рё РґР» РїСЂРѕРІР°Р№РґРµСЂР° РєР°СЂС‚ РґРѕР»Р¶РµРЅ Р±С‹С‚СЊ РѕРїСЂРµРґРµР»РµРЅ MapKey
     */
    public static boolean hasMapKey(MapProviderType providerType) {
        return !providersWithoutMapKeys.contains(providerType);
    }

    /**
     * @see #hasMapKey(MapProviderType)
     */
    @SuppressWarnings({"JavaDoc"})
    public static boolean hasMapKey(String providerName) {
        MapProviderType mapProviderType = MapProviderType.valueOf(providerName.toLowerCase());
        return hasMapKey(mapProviderType);
    }
}